/*
 * @Author: TC
 * @Date: 2021-09-27 15:14:11
 * @Last Modified by: TC
 * @Last Modified time: 2025-06-20 14:26:20
 */

import { Prefab, Vec2, director, Node, Canvas, Camera } from "cc";
import { GAME_STATE } from "../../Const/EnumConst";
import { UserInfo } from "../../Data/GameData";
import { MainCamera } from "../../Game/Camera/MainCamera";
import { EntityHero } from "../../Game/Entity/EntityHero";

//游戏数据类
export class GameDataManager {
    constructor() {}

    public userInfo: UserInfo = new UserInfo(); //用户信息
    public loadingPre: Prefab = null; //加载窗口
    public tipPre: Prefab = null; //全局提示
    public waitPre: Prefab = null; //全局等待
    public gameScale: number = 1;
    public currGate: number = 1;
    public xMax: number = 0;
    public maxLevel: number = 500;
    public cameraPos: Vec2;
    public currLevel: number = 0; //当前关卡
    public currScene: string = "load"; //当前场景
    public gameState: GAME_STATE; //当前游戏状态
    public roleNode: Node = null;
    public ui2dInfoLayer: Node = null; //人物UI
    public mainCamera: MainCamera = null; //主摄像机
    public entityHero: EntityHero = null; //英雄实例

    private static dataManager: GameDataManager = null;

    public static get instance(): GameDataManager {
        return GameDataManager.dataManager
            ? GameDataManager.dataManager
            : (GameDataManager.dataManager = new GameDataManager());
    }

    public getCanvas(): Node {
        return director.getScene().getChildByName("Canvas") as unknown as Node;
    }

    public init(): void {}
}

export const gameDataMgr: GameDataManager = GameDataManager.instance;
